package com.cskaoyan.service;

import com.cskaoyan.bean.VO.AdminDashboardVO;
import com.cskaoyan.mapper.MarketGoodsMapper;
import com.cskaoyan.mapper.MarketGoodsProductMapper;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wenkaikai
 * @since 2022/08/15 10:40
 */
@Service
@Transactional
public class AdminDashboardServiceImpl implements AdminDashboardService {


    @Autowired
    MarketGoodsMapper marketGoodsMapper;

    @Autowired
    MarketOrderMapper marketOrderMapper;

    @Autowired
    MarketGoodsProductMapper marketGoodsProductMapper;

    @Autowired
    MarketUserMapper marketUserMapper;

    /**
     * 查询：
     * 商品数量、订单数量、货品数量、用户总数
     *
     * @return
     */
    @Override
    public AdminDashboardVO queryDashboardParam() {
        long goodsTotal = marketGoodsMapper.countByExample(null);
        long orderTotal = marketOrderMapper.countByExample(null);
        long productTotal = marketGoodsProductMapper.countByExample(null);
        long userTotal = marketUserMapper.countByExample(null);
        AdminDashboardVO adminDashboardVO = new AdminDashboardVO();
        adminDashboardVO.setGoodsTotal(goodsTotal);
        adminDashboardVO.setOrderTotal(orderTotal);
        adminDashboardVO.setProductTotal(productTotal);
        adminDashboardVO.setUserTotal(userTotal);
        return adminDashboardVO;
    }
}